<!-- 历史需求单 -->
<template>
    <div>
        <el-button :disabled="disabled" @click="handleQuery">
            历史需求单
        </el-button>

        <el-dialog draggable v-model="dialogTableVisible" title="查询历史需求单" width="75%">
            <el-table :data="gridData" max-height="400">
                <el-table-column property="reqNo" label="需求单编号" min-width="120px" show-overflow-tooltip/>
                <el-table-column property="reqItemNo" label="需求单项号" min-width="120px" show-overflow-tooltip/>
                <el-table-column property="reqItemStatus" label="需求单明细状态" min-width="120px"
                                 show-overflow-tooltip>
                    <template v-slot="{row}">
                        <DictTag :dict-list="req_status" :dict-key="row.reqItemStatus" />
                    </template>
                </el-table-column>
                <el-table-column property="reportFactoryName" label="提报工厂" min-width="120px" show-overflow-tooltip>
                    <template v-slot="{row}">
                        {{ row.reportFactoryName || row.reportFactoryCode }}
                    </template>
                </el-table-column>
                <el-table-column property="submitQuantity" label="提报数量" min-width="90px" show-overflow-tooltip/>
                <el-table-column property="approveNum" label="审批数量 " min-width="90px" show-overflow-tooltip/>
                <el-table-column property="createTime" label="创建日期 " min-width="120px" show-overflow-tooltip/>
                <el-table-column property="materialDesc" label="物料描述 " min-width="120px" show-overflow-tooltip/>
                <el-table-column property="materialCode" label="物料编码 " min-width="120px" show-overflow-tooltip/>
            </el-table>
        </el-dialog>
    </div>
</template>

<script setup>
import {getCurrentInstance, reactive, ref} from 'vue'
import {doGet, doPost, doPut, doDelete, doDownload} from '@/config/http'
import {echoFactory} from "@/utils/echoDescription";

const {proxy} = getCurrentInstance();
const svc = ref('peas-module-plan-biz')
const {req_status} = proxy.useDict('req_status')

const props = defineProps({
    params: Object,
    disabled: {
        type: Boolean,
        default: false
    },
});


const dialogTableVisible = ref(false)

const gridData = ref([])

function handleQuery() {
    if (!props.params) {
        proxy.$alert('请选择需要查询历史需求单信息的记录', "提示", {type: 'warning'})
        return false
    }
    doPost(svc.value, '/req/query-his-approve-req', props.params,true).then(res => {
        gridData.value = res
        dialogTableVisible.value = true
        // echoFactory(gridData.value,['reportFactoryCode'],['reportFactoryName'])

    }).catch(e => {
        console.error(e)
    })
}
</script>
<style scoped>
.el-button--text {
    margin-right: 15px;
}

.el-select {
    width: 300px;
}

.el-input {
    width: 300px;
}

.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>
